package com.tanhua.server.controller;

import com.tanhua.domain.vo.UserInfoVo;
import com.tanhua.server.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/users")
public class UserInfoController {
    @Autowired
    private UserService userService;

    @GetMapping
    public ResponseEntity getUserInfo(Long userID, Long huanxinID, @RequestHeader("Authorization") String token) {
        UserInfoVo vo = userService.getUserInfo(userID, huanxinID, token);
        return ResponseEntity.ok(vo);
    }

    @PutMapping
    public ResponseEntity updateUserInfo(@RequestBody UserInfoVo vo, @RequestHeader("Authorization") String token) {
        userService.updateUserInfo(token, vo);
        return ResponseEntity.ok(null);
    }
        @PostMapping("/header")
        public ResponseEntity updatePhoto(MultipartFile headPhoto,@RequestHeader("Authorization") String token){
            userService.updatePhoto(headPhoto, token);
            return ResponseEntity.ok(null);
        }
}
